package com.leanin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.leanin.domain.PlanInfo;
import com.leanin.response.DataOutResponse;
import com.leanin.service.PlanInfoService;

@RestController
@RequestMapping(value="plan")
public class PlanInfoController {

	@Autowired
	private PlanInfoService planInfoService;
	
	
	@GetMapping("findPlanList")
	public DataOutResponse findPlanList(@RequestParam int page,@RequestParam int pageSize,@RequestParam(required=false) String planName,@RequestParam int planType) {
		return planInfoService.findPlanList(page, pageSize, planName,planType);
	}
	
	@GetMapping("updatePlanStatus")
	public DataOutResponse updatePlanStatus(@RequestParam String planNum,@RequestParam int status) {
		return planInfoService.updatePlanStatus(planNum, status);
	}
	
	@PostMapping("addPlanInfo")
	public DataOutResponse addPlanInfo(@RequestBody PlanInfo planInfo) {
		return planInfoService.addPlanInfo(planInfo);
	}
	
	@GetMapping("findPlanInfoById")
	public DataOutResponse findPlanInfoById(@RequestParam String planNum) {
		return planInfoService.findPlanInfoById(planNum);
	}
	
	@PostMapping("updatePlanInfo")
	public DataOutResponse updatePlanInfo(@RequestBody PlanInfo planInfo) {
		return planInfoService.updatePlanInfo(planInfo);
	}
}
